package com.zhny.protocol_v3_008.constant;

public enum ReplyCode {
	 SUCCESS("响应成功",201),
	 BEGIN_REMOTE_CONTROL("遥控命令开始",202),
	 FINISHED_REMOTE_CONTROL("遥控命令执行完成",203),
	 FAILED("响应失败",211),
	 ERROR_HEAD("包头错误",212),
	 ERROR_PACKAGE_TYPE("包类型错误",213),
	 ERROR_DATE("时间戳错误",214),
	 ERROR_DEVICE_FLAG("设备标识符错误",215),
	 ERROR_DEVICE_TYPE("设备类型错误",216),
	 ERROR_LENGTH("数据区长度错误",217),
	 ERROR_CRC("CRC校验错误",218),
	 ERROR_END("包尾错误",219),
	 ERROR_BASE("基地标识错误",220);
	
	private String name;
	private int code;
	
	private ReplyCode(String name, int code) {
		this.name = name;
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public int getCode() {
		return code;
	}
	
	public static String getName(int code) {
		if(code == 201) return "响应成功";
		for(ReplyCode rc : ReplyCode.values()) {
			if(rc.code == code)
				return rc.getName();
		}
		return null;
	}
	
	public static void main(String...strings) {
		System.out.println(ReplyCode.BEGIN_REMOTE_CONTROL.getCode());
	}
	
}
